package color.koitq.picker.adapter;

import android.graphics.Color;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;

import color.koitq.picker.R;
import color.koitq.picker.entity.Tab3Model;

public class Tab3Adapter extends BaseQuickAdapter<Tab3Model, BaseViewHolder> {
    public Tab3Adapter() {
        super(R.layout.item_tab3);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, Tab3Model model) {
        Glide.with(getContext()).load(model.img).placeholder(R.mipmap.ic_launcher).into((ImageView) baseViewHolder.findView(R.id.img));
        baseViewHolder.setBackgroundColor(R.id.iv1, Color.parseColor(model.color1));
        baseViewHolder.setBackgroundColor(R.id.iv2, Color.parseColor(model.color2));
        baseViewHolder.setBackgroundColor(R.id.iv3, Color.parseColor(model.color3));
        baseViewHolder.setBackgroundColor(R.id.iv4, Color.parseColor(model.color4));
        baseViewHolder.setBackgroundColor(R.id.iv5, Color.parseColor(model.color5));
        StaggeredGridLayoutManager.LayoutParams itemlayoutParams =
                (StaggeredGridLayoutManager.LayoutParams) baseViewHolder.getView(R.id.cl).getLayoutParams();
        int position = getItemPosition(model);
        if (position  == 0) {
            itemlayoutParams.height = QMUIDisplayHelper.dp2px(getContext(), 280);
        }else {
            itemlayoutParams.height = QMUIDisplayHelper.dp2px(getContext(), 180);
        }
        baseViewHolder.getView(R.id.cl).setLayoutParams(itemlayoutParams);
    }
}
